<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>English Potential Assessment - Target Proficiency Level</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
    <style>
      body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
        background-color: #fff;
        color: #333;
      }

      .dark body {
        background-color: #1a1a1a;
        color: #f5f5f5;
      }

      /* 进度条样式 */
      .progress-container {
        height: 4px;
        width: 100%;
        background-color: #f0f0f0;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
      }

      .progress-bar {
        height: 100%;
        background-color: #007aff;
        width: 50%; /* 8步，第四步 */
      }

      .dark .progress-container {
        background-color: #333;
      }

      /* 顶部导航 */
      .top-nav {
        padding: 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }

      .back-btn {
        color: #007aff;
        font-size: 1.25rem;
        cursor: pointer;
      }

      /* 内容区域 */
      .content {
        max-width: 600px;
        margin: 0 auto;
        padding: 1rem;
      }

      /* 选项卡片样式 */
      .option-card {
        background-color: #f9f9f9;
        border-radius: 16px;
        padding: 16px;
        margin-bottom: 16px;
        display: flex;
        align-items: center;
        cursor: pointer;
        position: relative;
        transition: all 0.2s;
        border: 2px solid transparent;
        height: 100%;
      }

      .option-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      }

      .option-card.selected {
        border-color: #007aff;
      }

      .option-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 70%;
      }

      .option-icon {
        width: 45px;
        height: 45px;
        background-color: #e6f2ff;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 8px;
      }

      .option-text {
        text-align: center;
        max-width: 100%;
      }

      .option-radio {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        border: 2px solid #d1d1d6;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
        flex-shrink: 0;
      }

      .option-card.selected .option-radio {
        border-color: #007aff;
      }

      .option-card.selected .option-radio::after {
        content: '';
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #007aff;
      }

      /* 按钮样式 */
      .btn-primary {
        background-color: #4187ff;
        color: white;
        padding: 0.75rem 1.5rem;
        border-radius: 10px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        display: inline-flex;
        align-items: center;
        width: 100%;
        justify-content: center;
        border: none;
      }

      .btn-primary:hover {
        background-color: #3672db;
      }

      .btn-primary:disabled {
        background-color: #c7c7cc;
        cursor: not-allowed;
      }

      /* 适配黑暗模式 */
      .dark .option-card {
        background-color: #2d3748;
        border-color: #4a5568;
      }

      .dark .option-card.selected {
        border-color: #007aff;
      }

      .dark .option-icon {
        background-color: #1a365d;
      }

      .dark .option-radio {
        border-color: #718096;
      }

      /* 主题切换按钮 */
      .theme-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background-color: #007aff;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        z-index: 1000;
      }

      .theme-toggle:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
      }

      /* 网格布局 */
      .options-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        margin-bottom: 24px;
      }

      .nav-progress-container {
        display: flex;
        align-items: center;
        margin-bottom: 40px;
        gap: 15px;
      }

      .back-button {
        width: 30px;
        height: 30px;
        border: none;
        background: none;
        cursor: pointer;
        color: #2b85e4;
        font-size: 20px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .back-button svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
      }

      .progress-bar {
        flex: 1;
        height: 6px;
        background-color: #e0e0e0;
        border-radius: 3px;
      }

      .progress {
        height: 100%;
        width: 23.31%;
        background-color: #2b85e4;
        border-radius: 3px;
      }
    </style>
    <script>
      // 检查深色模式
      function checkDarkMode() {
        if (
          localStorage.getItem('darkMode') === 'true' ||
          (localStorage.getItem('darkMode') === null && window.matchMedia('(prefers-color-scheme: dark)').matches)
        ) {
          document.documentElement.classList.add('dark')
          return true
        }
        return false
      }

      // 切换深色/浅色模式
      function toggleDarkMode() {
        if (document.documentElement.classList.contains('dark')) {
          document.documentElement.classList.remove('dark')
          localStorage.setItem('darkMode', 'false')
          document.getElementById('theme-icon').className = 'fas fa-moon'
        } else {
          document.documentElement.classList.add('dark')
          localStorage.setItem('darkMode', 'true')
          document.getElementById('theme-icon').className = 'fas fa-sun'
        }
      }

      // 选择选项
      function selectOption(id) {
        // 取消所有选项的选中状态
        document.querySelectorAll('.option-card').forEach(card => {
          card.classList.remove('selected')
        })

        // 选中当前选项
        document.getElementById(id).classList.add('selected')
        // 只有在用户手动选择时才继续下一步
        continueNext()
      }

      // 继续下一步
      function continueNext() {
        // 获取选中的选项
        const selectedOption = document.querySelector('.option-card.selected')
        if (selectedOption) {
          const optionId = selectedOption.id

          // 获取页面标题和当前页面名称
          const pageTitle = document.querySelector('.text-3xl').textContent.trim()
          const pageName = window.location.pathname.split('/').pop().split('.')[0]
          const selectedTitle = selectedOption.querySelector('.text-sm').textContent.trim()

          // 创建数据对象
          const data = {
            title: pageTitle,
            value: selectedTitle,
            targetLevel: optionId,
          }

          // 以JSON格式存储到localStorage
          localStorage.setItem(pageName, JSON.stringify(data))

          // 保留原有存储方式，以保证兼容性
          localStorage.setItem('targetLevel', optionId)

          // 跳转到下一页
          window.location.href = '/setYour.html'
        }
      }

      // 当DOM加载完成
      document.addEventListener('DOMContentLoaded', function () {
        const isDark = checkDarkMode()
        document.getElementById('theme-icon').className = isDark ? 'fas fa-sun' : 'fas fa-moon'

        // 从本地存储中恢复之前的选择（如果有）
        const savedOption = localStorage.getItem('targetLevel')
        if (savedOption) {
          // 取消所有选项的选中状态
          document.querySelectorAll('.option-card').forEach(card => {
            card.classList.remove('selected')
          })
          // 选中之前保存的选项
          document.getElementById(savedOption).classList.add('selected')
          // 不调用 continueNext 函数，避免自动跳转
        }
      })
    </script>
  </head>
  <body>
    <!-- 主内容区 -->
    <div class="content">
      <div class="nav-progress-container">
        <button class="back-button" onclick="window.location.href='/whyDoYou.html'">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
            <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" />
          </svg>
        </button>
        <div class="progress-bar">
          <div class="progress"></div>
        </div>
      </div>
      <!-- 页面标题 -->
      <h1 class="text-3xl font-bold text-center mb-6 text-[#0B4983]">What level of English do you aim to achieve?</h1>

      <!-- 选项网格布局 -->
      <div class="options-grid">
        <!-- 选项1：自信交流 -->
        <div id="speak_with_natives" class="option-card" onclick="selectOption('speak_with_natives')">
          <div class="option-content">
            <div class="option-icon">
              <img src="./imgs/speak.png" />
            </div>
            <div class="option-text">
              <h3 class="text-sm font-medium">Speak confidently with natives</h3>
            </div>
          </div>
          <div class="option-radio"></div>
        </div>

        <!-- 选项2：看电影无字幕 -->
        <div id="watch_without_subtitles" class="option-card" onclick="selectOption('watch_without_subtitles')">
          <div class="option-content">
            <div class="option-icon">
              <img src="./imgs/watch.png" />
            </div>
            <div class="option-text">
              <h3 class="text-sm font-medium">Watch movies without subtitles</h3>
            </div>
          </div>
          <div class="option-radio"></div>
        </div>

        <!-- 选项3：轻松理解对话 -->
        <div id="understand_effortlessly" class="option-card" onclick="selectOption('understand_effortlessly')">
          <div class="option-content">
            <div class="option-icon">
              <img src="./imgs/understand.png" />
            </div>
            <div class="option-text">
              <h3 class="text-sm font-medium">Understand conversations effortlessly</h3>
            </div>
          </div>
          <div class="option-radio"></div>
        </div>

        <!-- 选项4：流利阅读文本 -->
        <div id="read_fluently" class="option-card" onclick="selectOption('read_fluently')">
          <div class="option-content">
            <div class="option-icon">
              <img src="./imgs/read.png" />
            </div>
            <div class="option-text">
              <h3 class="text-sm font-medium">Read texts fluently</h3>
            </div>
          </div>
          <div class="option-radio"></div>
        </div>
      </div>

      <!-- 继续按钮 -->
      <!-- <button id="continue-btn" class="btn-primary" disabled onclick="continueNext()">
        继续
        <i class="fas fa-arrow-right ml-2"></i>
      </button> -->
    </div>

    <!-- 主题切换按钮 -->
    <div class="theme-toggle" onclick="toggleDarkMode()">
      <i id="theme-icon" class="fas fa-moon"></i>
    </div>
  </body>
</html>
